/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tda_tipoGasolinaDAOImpl implements orm.dao.Tda_tipoGasolinaDAO {
	public Tda_tipoGasolina loadTda_tipoGasolinaByORMID(int tga_id) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return loadTda_tipoGasolinaByORMID(session, tga_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina getTda_tipoGasolinaByORMID(int tga_id) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return getTda_tipoGasolinaByORMID(session, tga_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByORMID(int tga_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return loadTda_tipoGasolinaByORMID(session, tga_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina getTda_tipoGasolinaByORMID(int tga_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return getTda_tipoGasolinaByORMID(session, tga_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByORMID(PersistentSession session, int tga_id) throws PersistentException {
		try {
			return (Tda_tipoGasolina) session.load(orm.Tda_tipoGasolina.class, new Integer(tga_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina getTda_tipoGasolinaByORMID(PersistentSession session, int tga_id) throws PersistentException {
		try {
			return (Tda_tipoGasolina) session.get(orm.Tda_tipoGasolina.class, new Integer(tga_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByORMID(PersistentSession session, int tga_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tda_tipoGasolina) session.load(orm.Tda_tipoGasolina.class, new Integer(tga_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina getTda_tipoGasolinaByORMID(PersistentSession session, int tga_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tda_tipoGasolina) session.get(orm.Tda_tipoGasolina.class, new Integer(tga_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina[] listTda_tipoGasolinaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return listTda_tipoGasolinaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina[] listTda_tipoGasolinaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return listTda_tipoGasolinaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina[] listTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tda_tipoGasolina as Tda_tipoGasolina");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tda_tipoGasolina[]) list.toArray(new Tda_tipoGasolina[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina[] listTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tda_tipoGasolina as Tda_tipoGasolina");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tda_tipoGasolina[]) list.toArray(new Tda_tipoGasolina[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return loadTda_tipoGasolinaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return loadTda_tipoGasolinaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tda_tipoGasolina[] tda_tipoGasolinas = listTda_tipoGasolinaByQuery(session, condition, orderBy);
		if (tda_tipoGasolinas != null && tda_tipoGasolinas.length > 0)
			return tda_tipoGasolinas[0];
		else
			return null;
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tda_tipoGasolina[] tda_tipoGasolinas = listTda_tipoGasolinaByQuery(session, condition, orderBy, lockMode);
		if (tda_tipoGasolinas != null && tda_tipoGasolinas.length > 0)
			return tda_tipoGasolinas[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTda_tipoGasolinaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return iterateTda_tipoGasolinaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTda_tipoGasolinaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.PruebaPDS1PersistentManager.instance().getSession();
			return iterateTda_tipoGasolinaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tda_tipoGasolina as Tda_tipoGasolina");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTda_tipoGasolinaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tda_tipoGasolina as Tda_tipoGasolina");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina createTda_tipoGasolina() {
		return new orm.Tda_tipoGasolina();
	}
	
	public boolean save(orm.Tda_tipoGasolina tda_tipoGasolina) throws PersistentException {
		try {
			orm.PruebaPDS1PersistentManager.instance().saveObject(tda_tipoGasolina);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tda_tipoGasolina tda_tipoGasolina) throws PersistentException {
		try {
			orm.PruebaPDS1PersistentManager.instance().deleteObject(tda_tipoGasolina);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tda_tipoGasolina tda_tipoGasolina)throws PersistentException {
		try {
			if(tda_tipoGasolina.getTdp_preciopre() != null) {
				tda_tipoGasolina.getTdp_preciopre().tda_tipoGasolina.remove(tda_tipoGasolina);
			}
			
			return delete(tda_tipoGasolina);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tda_tipoGasolina tda_tipoGasolina, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tda_tipoGasolina.getTdp_preciopre() != null) {
				tda_tipoGasolina.getTdp_preciopre().tda_tipoGasolina.remove(tda_tipoGasolina);
			}
			
			try {
				session.delete(tda_tipoGasolina);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tda_tipoGasolina tda_tipoGasolina) throws PersistentException {
		try {
			orm.PruebaPDS1PersistentManager.instance().getSession().refresh(tda_tipoGasolina);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tda_tipoGasolina tda_tipoGasolina) throws PersistentException {
		try {
			orm.PruebaPDS1PersistentManager.instance().getSession().evict(tda_tipoGasolina);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tda_tipoGasolina loadTda_tipoGasolinaByCriteria(Tda_tipoGasolinaCriteria tda_tipoGasolinaCriteria) {
		Tda_tipoGasolina[] tda_tipoGasolinas = listTda_tipoGasolinaByCriteria(tda_tipoGasolinaCriteria);
		if(tda_tipoGasolinas == null || tda_tipoGasolinas.length == 0) {
			return null;
		}
		return tda_tipoGasolinas[0];
	}
	
	public Tda_tipoGasolina[] listTda_tipoGasolinaByCriteria(Tda_tipoGasolinaCriteria tda_tipoGasolinaCriteria) {
		return tda_tipoGasolinaCriteria.listTda_tipoGasolina();
	}
}
